package com.xnyzc.lhy.mis.mapper.sidebar;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xnyzc.lhy.common.component.config.GlobalConfig;
import com.xnyzc.lhy.mis.entity.param.cms.OfficeParam;
import com.xnyzc.lhy.mis.entity.sidebar.OaSysOffice;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 机构表 Mapper 接口
 * </p>
 *
 * @author lhy@xnyzc.com
 * @since 2019-07-17
 */
public interface OaSysOfficeMapper extends BaseMapper<OaSysOffice> {

    /**
     * 查询所有结构数据列表
     * @return
     */
    public List<OaSysOffice> findAllList(OaSysOffice office);

    /**
     * 查询数据列表，如果需要分页，请设置分页对象，如：entity.setPage(new Page<T>());
     * @return
     */
    public List<OaSysOffice> findList(GlobalConfig config);

    @Select("SELECT * " +
            "FROM oa_sys_office office " +
            "LEFT JOIN oa_sys_area area " +
            "ON office.area_id=area.area_id " +
            "WHERE office.parent_id <> 1 AND area.ad_code=#{cityId}")
    List<OaSysOffice> getCompanyByAdCode(@Param("cityId") String cityId);

    @Select("SELECT * " +
            "FROM oa_sys_office office " +
            "LEFT JOIN oa_sys_area area " +
            "ON office.area_id=area.area_id " +
            "WHERE office.parent_id <> 1 AND area.area_id=#{cityId}")
    List<OaSysOffice> getCompanyByAdId(@Param("cityId") String cityId);

    @Select("SELECT office_id,office.expand1 " +
            "FROM oa_sys_office office " +
            "LEFT JOIN oa_sys_area area " +
            "ON office.area_id=area.area_id " +
            "WHERE office.parent_id <> 1 AND area.ad_code=#{cityId}")
    List<com.xnyzc.lhy.order.entity.sidebar.OaSysOffice> getCompanysByAdCode(@Param("cityId") String cityId);

}
